<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //函数，为了解决今天100累加和，明天98累加和，后天6829累加和，诸如此类问题。
        //提高代码的重复使用率

        //求num1~num2的累加和
        function getsum(num1, num2) {
            var sum = 0;
            for (var i = num1; i <= num2; i++) {
                sum += i;

            }
            console.log(sum);

        }
        getsum(1, 100);
        getsum(10, 50);
    </script>
</head>

<body>

</body>

</html>